#!/bin/bash
export NDK_ROOT=/mnt/android_home/ndk/android-ndk-r28c
export TOOLCHAIN=$NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64
export CC=$TOOLCHAIN/bin/aarch64-linux-android21-clang
export CXX=$TOOLCHAIN/bin/aarch64-linux-android21-clang++
export STRIP=$TOOLCHAIN/bin/llvm-strip
export AR=$TOOLCHAIN/bin/llvm-ar
export RANLIB=$TOOLCHAIN/bin/llvm-ranlib
export SYSROOT=$TOOLCHAIN/sysroot
rm -rf /tmp/module/build/mp3lame/main
mkdir -p /tmp/module/build/mp3lame/main
cd /tmp/module/build/mp3lame/main

/opt/module/src/mp3lame/main/configure \
    --host=aarch64-linux-android \
    --prefix=/tmp/module/install/mp3lame/main \
    --disable-shared \
    --enable-static \
    --disable-gtktest \
    --disable-analyzer-hooks \
    --disable-mp3x \
    --disable-mp3rtp \
    --enable-dynamic-frontends \
    --enable-expopt=yes \
    --disable-frontend \
    --disable-debug \
    CC=$CC \
    CXX=$CXX \
    STRIP=$STRIP \
    AR=$AR \
    RANLIB=$RANLIB \
    CFLAGS="--sysroot=$SYSROOT -g -O2 -fPIC" \
    LDFLAGS="--sysroot=$SYSROOT -static"

 make -j$(nproc)
 make install